<?php
namespace app\api\controller;

use think\Controller;

  class Base extends Controller{
  	protected function _initialize()
    {
        header('content-type:text/html;charset=utf-8');
        header('Access-Control-Allow-Origin: *');
        header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
        header('Access-Control-Allow-Methods: GET, POST, PUT');
        ksort($_POST);
        ksort($_GET);
    }
		public function token(){
        $token = md5(mt_rand(111111,999999).time());
        return $token;
    }
		function ajaxmsg($msg = "", $status = 1, $data = '', $errcode = '')
{
    $json['msg'] = $msg;
    $json['status'] = $status;
    $json['data'] = $data;
		$json['token'] = $token;
    if ($errcode) {
        $json['errcode'] = $errcode;
    }
    echo json_encode($json, true);
    exit;
}
  }
  

?>